a=[]
shme={")":"(","]":"[","}":"{",">":"<"}
Q=input("Введите скобочную последовательность:")
for i in Q:
    if i in shme.values():
        a.append(i)
    elif i in shme.keys():
        if not a or a.pop()!=shme[i]:
            print(False)
            break
        else:
            continue
else:
  print(not a )
